<template>
  <div id="login">
    <div class="tabs">
      <ul :style="{ width: `${loginList.length * 100}px` }" class="tab-list">
        <li
          :class="activeIndex == index ? 'active' : ''"
          @click="toChildPage(index)"
          v-for="(page, index) in loginList"
          :key="index"
        >
          <router-link :to="'/login/' + page.childPath">{{page.tabTitle}}</router-link>
        </li>
      </ul>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
import mPhone from "../components/mPhone.vue";
import User from "../components/user.vue";
export default {
  name: "Login",
  data() {
    return {
      activeIndex: 0,
      loginList: [
        { tabTitle: "手机一键登录", childPath: "mPhone" },
        { tabTitle: "账户登录", childPath: "user" },
      ],
    };
  },
  methods: {
    toChildPage(index) {
      this.activeIndex = index;
    },
  },
  components: { mPhone, User },
};
</script>

<style scoped="scoped">
#login {
  padding: 0.48rem 0.4rem 0 0.4rem;
  background: #fff;
}
.tabs {
    margin-bottom: 0.24rem;
  overflow: auto;
}
.tab-list {
  display: flex;
  list-style: none;
  text-align: center;
}
.tab-list > li {
  width: 2rem;
  height: 0.5rem;
  position: relative;
  line-height: 0;
  font-size: 0.26rem;
  line-height: 0.5rem;
}
.tab-list > li:nth-of-type(1) {
  border-right: 1px solid #3e3e3e;
}
.tab-list > li.active::after {
  content: "";
  display: inline-block;
  height: 0.04rem;
  background-color: orangered;
  width: 80%;
  position: absolute;
  bottom: 0;
  left: 0.2rem;
}
.tab-list > li a{
  color: #3e3e3e;
  text-decoration: none;
}
.tab-list > li a:hover {
  color: #fe4320;
}
</style>